<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" href="../static/css/reset.css">
    <link rel="stylesheet" href="../static/css/base.css">
    <link rel="stylesheet" href="../static/css/login.css">   
    <style type="text/css">
    </style>
    <title>注册</title>
</head>
<body>
    <div class="register-container container">
        <div class="row">
            <div class="register span6">
                <form>
                    <!-- <h2><span class="red"><strong>龙锟汽车</strong></span></h2> -->
                    <!-- <div class="item"> 
                        <label for="firstname">
                        姓名  
                        </label>
                        <input type="text" class="a" id="firstname" name="firstname" placeholder="请输入您的姓名">
                    </div> -->
                    <div class="item">
                        <label for="tel">电话</label>
                        <input type="text" class="a" id="tel" name="tel" placeholder="请输入您的电话">
                    </div>
                    <!-- <div class="item">
                        <label for="password">密码</label>
                        <input type="password" class="a" id="password" name="password" placeholder="请输入您的密码">
                    </div>
                    <div class="item">
                        <label for="password1"></label>
                        <input type="password" class="a" id="password1" name="password1" placeholder="请再次输入密码">
                    </div> -->
                    <div class="item">
                        <label for="password">验证码</label>
                        <input type="password" class="a" id="code1" autocomplete="off" name="" placeholder="短信验证码">
                        <input type="button" id="btnSendCode1" class="btn btn-default" value="获取验证码" onclick="sendMessage1()">
                    </div>
                    <div class="submit">注册登陆</div>
                </form>
            </div>
        </div>
    </div>
    <script src="../static/js/jquery.min.js"></script>
    <script src="../static/js/rem.js"></script>
    <script src="../static/js/base.js"></script>
    <script src="../static/js/login.js"></script>
    <script>
        var phoneReg = /(^1[3|4|5|7|8]\d{9}$)|(^09\d{8}$)/;//手机号正则 
        var count = 60; //间隔函数，1秒执行
        var InterValObj1; //timer变量，控制时间
        var curCount1;//当前剩余秒数
        /*第一*/
        function sendMessage1() {
            curCount1 = count;		 		 
            var phone = $.trim($('#tel').val());
            if (!phoneReg.test(phone)) {
                alert("请输入有效的手机号码"); 
                return false;
            }
            //设置button效果，开始计时
            $("#btnSendCode1").attr("disabled", "true");
            $("#btnSendCode1").val( + curCount1 + "秒再获取");
            InterValObj1 = window.setInterval(SetRemainTime1, 1000); //启动计时器，1秒执行一次
            //向后台发送处理数据
            var appCode = 'fxjsms';
            var templateparam = Math.round((Math.random()*9000) + 1000);
            $.ajax({
                type: "GET",
                url: baseUrl + "/rest/base/sendsms?appCode="+appCode+"&phonenumbers="+phone+"&templateparam="+templateparam,
                contentType:"application/json;charset=UTF-8",
                success: function(data){
                    let e = JSON.parse(data);
                    if(e.ok){
                        messageBox("短信验证码已发送！");
                    }else{
                        messageBox(e.message);
                    }
                }
            });
                
        }
        function SetRemainTime1() {
            if (curCount1 == 0) {                
                window.clearInterval(InterValObj1);//停止计时器
                $("#btnSendCode1").removeAttr("disabled");//启用按钮
                $("#btnSendCode1").val("重新发送");
            }
            else {
                curCount1--;
                $("#btnSendCode1").val( + curCount1 + "秒再获取");
            }
        } 
    </script>
</body>
</html>